/*
 * DigitShopAdminItemForm.java
 */

package digitshopadminapp;

import Entities.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;

public class DigitShopAdminItemForm extends javax.swing.JDialog {

    // Class variables
    protected Stock_item theItem = new Stock_item();
    protected Category theCategory = new Category();
    protected Store theStore = new Store();
    protected Stock theStock = new Stock();
    protected Discount_rule theDiscountRule = new Discount_rule();
    protected Discount theDiscount = new Discount();

    public DigitShopAdminItemForm(java.awt.Frame parent) {
        super(parent);
        initComponents();
        //getRootPane().setDefaultButton(closeButton);
        
    }

    public DigitShopAdminItemForm(Stock_item item, Category category, Store store, Stock stock,Discount_rule discountrule){
        this. theItem = item;
        this.theCategory = category;
        this.theStore = store;
        this.theStock = stock;
        this.theDiscountRule = discountrule;
    }

    @Action public void closeItemForm() {
        dispose();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        closeButton = new javax.swing.JButton();
        jLabel_ItemQuantity = new javax.swing.JLabel();
        jLabel_ItemRemoveDate = new javax.swing.JLabel();
        jLabel_OnSale = new javax.swing.JLabel();
        jTextField_ItemName = new javax.swing.JTextField();
        jTextField_ItemTaxRate = new javax.swing.JTextField();
        jLabel_StoreID = new javax.swing.JLabel();
        jTextField_ItemID = new javax.swing.JTextField();
        jTextField_ItemCost = new javax.swing.JTextField();
        jTextField_ItemExpireDate = new javax.swing.JTextField();
        jLabel_ItemForm = new javax.swing.JLabel();
        jTextField_ItemDescription = new javax.swing.JTextField();
        jLabel_TaxRate = new javax.swing.JLabel();
        jTextField_StoreID = new javax.swing.JTextField();
        jLabel_Category = new javax.swing.JLabel();
        jTextField_ItemSellPrice = new javax.swing.JTextField();
        jLabel_ExpirationDate = new javax.swing.JLabel();
        jTextField_ItemProfitPercentage = new javax.swing.JTextField();
        jLabel_ItemAddDate = new javax.swing.JLabel();
        jTextField_ItemQuantity = new javax.swing.JTextField();
        jButton_SaveItem = new javax.swing.JButton();
        jLabel_ItemID = new javax.swing.JLabel();
        jTextArea_ItemAddDate = new javax.swing.JTextArea();
        jLabel_ItemName = new javax.swing.JLabel();
        jTextArea_ItemSoldDate = new javax.swing.JTextArea();
        jLabel_Description = new javax.swing.JLabel();
        jLabel_Cost = new javax.swing.JLabel();
        jLabel_SellPrice = new javax.swing.JLabel();
        jLabel_Profit = new javax.swing.JLabel();
        jComboBox_ItemCategory = new javax.swing.JComboBox();
        jButton_NewCategory = new javax.swing.JButton();
        jComboBox_ItemDiscountRule = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(digitshopadminapp.DigitShopAdminApp.class).getContext().getResourceMap(DigitShopAdminItemForm.class);
        setTitle(resourceMap.getString("title")); // NOI18N
        setModal(true);
        setName("aboutBox"); // NOI18N
        setResizable(false);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(digitshopadminapp.DigitShopAdminApp.class).getContext().getActionMap(DigitShopAdminItemForm.class, this);
        closeButton.setAction(actionMap.get("closeAboutBox")); // NOI18N
        closeButton.setName("closeButton"); // NOI18N

        jLabel_ItemQuantity.setText(resourceMap.getString("jLabel_ItemQuantity.text")); // NOI18N
        jLabel_ItemQuantity.setName("jLabel_ItemQuantity"); // NOI18N

        jLabel_ItemRemoveDate.setText(resourceMap.getString("jLabel_ItemRemoveDate.text")); // NOI18N
        jLabel_ItemRemoveDate.setName("jLabel_ItemRemoveDate"); // NOI18N

        jLabel_OnSale.setText(resourceMap.getString("jLabel_OnSale.text")); // NOI18N
        jLabel_OnSale.setName("jLabel_OnSale"); // NOI18N

        jTextField_ItemName.setText(resourceMap.getString("jTextField_ItemName.text")); // NOI18N
        jTextField_ItemName.setName("jTextField_ItemName"); // NOI18N
        jTextField_ItemName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField_ItemNameActionPerformed(evt);
            }
        });

        jTextField_ItemTaxRate.setText(resourceMap.getString("jTextField_ItemTaxRate.text")); // NOI18N
        jTextField_ItemTaxRate.setName("jTextField_ItemTaxRate"); // NOI18N
        jTextField_ItemTaxRate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField_ItemTaxRateActionPerformed(evt);
            }
        });

        jLabel_StoreID.setText(resourceMap.getString("jLabel_StoreID.text")); // NOI18N
        jLabel_StoreID.setName("jLabel_StoreID"); // NOI18N

        jTextField_ItemID.setText(resourceMap.getString("jTextField_ItemID.text")); // NOI18N
        jTextField_ItemID.setName("jTextField_ItemID"); // NOI18N
        jTextField_ItemID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField_ItemIDActionPerformed(evt);
            }
        });

        jTextField_ItemCost.setText(resourceMap.getString("jTextField_ItemCost.text")); // NOI18N
        jTextField_ItemCost.setName("jTextField_ItemCost"); // NOI18N
        jTextField_ItemCost.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField_ItemCostActionPerformed(evt);
            }
        });

        jTextField_ItemExpireDate.setText(resourceMap.getString("jTextField_ItemExpireDate.text")); // NOI18N
        jTextField_ItemExpireDate.setName("jTextField_ItemExpireDate"); // NOI18N
        jTextField_ItemExpireDate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField_ItemExpireDateActionPerformed(evt);
            }
        });

        jLabel_ItemForm.setFont(resourceMap.getFont("jLabel_ItemForm.font")); // NOI18N
        jLabel_ItemForm.setText(resourceMap.getString("jLabel_ItemForm.text")); // NOI18N
        jLabel_ItemForm.setName("jLabel_ItemForm"); // NOI18N

        jTextField_ItemDescription.setText(resourceMap.getString("jTextField_ItemDescription.text")); // NOI18N
        jTextField_ItemDescription.setName("jTextField_ItemDescription"); // NOI18N

        jLabel_TaxRate.setText(resourceMap.getString("jLabel_TaxRate.text")); // NOI18N
        jLabel_TaxRate.setName("jLabel_TaxRate"); // NOI18N

        jTextField_StoreID.setText(resourceMap.getString("jTextField_StoreID.text")); // NOI18N
        jTextField_StoreID.setName("jTextField_StoreID"); // NOI18N
        jTextField_StoreID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField_StoreIDActionPerformed(evt);
            }
        });

        jLabel_Category.setText(resourceMap.getString("jLabel_Category.text")); // NOI18N
        jLabel_Category.setName("jLabel_Category"); // NOI18N

        jTextField_ItemSellPrice.setText(resourceMap.getString("jTextField_ItemSellPrice.text")); // NOI18N
        jTextField_ItemSellPrice.setName("jTextField_ItemSellPrice"); // NOI18N
        jTextField_ItemSellPrice.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField_ItemSellPriceActionPerformed(evt);
            }
        });

        jLabel_ExpirationDate.setText(resourceMap.getString("jLabel_ExpirationDate.text")); // NOI18N
        jLabel_ExpirationDate.setName("jLabel_ExpirationDate"); // NOI18N

        jTextField_ItemProfitPercentage.setText(resourceMap.getString("jTextField_ItemProfitPercentage.text")); // NOI18N
        jTextField_ItemProfitPercentage.setName("jTextField_ItemProfitPercentage"); // NOI18N

        jLabel_ItemAddDate.setText(resourceMap.getString("jLabel_ItemAddDate.text")); // NOI18N
        jLabel_ItemAddDate.setName("jLabel_ItemAddDate"); // NOI18N

        jTextField_ItemQuantity.setText(resourceMap.getString("jTextField_ItemQuantity.text")); // NOI18N
        jTextField_ItemQuantity.setName("jTextField_ItemQuantity"); // NOI18N
        jTextField_ItemQuantity.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField_ItemQuantityActionPerformed(evt);
            }
        });

        jButton_SaveItem.setText(resourceMap.getString("jButton_SaveItem.text")); // NOI18N
        jButton_SaveItem.setName("jButton_SaveItem"); // NOI18N

        jLabel_ItemID.setText(resourceMap.getString("jLabel_ItemID.text")); // NOI18N
        jLabel_ItemID.setName("jLabel_ItemID"); // NOI18N

        jTextArea_ItemAddDate.setColumns(20);
        jTextArea_ItemAddDate.setRows(5);
        jTextArea_ItemAddDate.setName("jTextArea_ItemAddDate"); // NOI18N

        jLabel_ItemName.setText(resourceMap.getString("jLabel_ItemName.text")); // NOI18N
        jLabel_ItemName.setName("jLabel_ItemName"); // NOI18N

        jTextArea_ItemSoldDate.setColumns(20);
        jTextArea_ItemSoldDate.setRows(5);
        jTextArea_ItemSoldDate.setName("jTextArea_ItemSoldDate"); // NOI18N

        jLabel_Description.setText(resourceMap.getString("jLabel_Description.text")); // NOI18N
        jLabel_Description.setName("jLabel_Description"); // NOI18N

        jLabel_Cost.setText(resourceMap.getString("jLabel_Cost.text")); // NOI18N
        jLabel_Cost.setName("jLabel_Cost"); // NOI18N

        jLabel_SellPrice.setText(resourceMap.getString("jLabel_SellPrice.text")); // NOI18N
        jLabel_SellPrice.setName("jLabel_SellPrice"); // NOI18N

        jLabel_Profit.setText(resourceMap.getString("jLabel_Profit.text")); // NOI18N
        jLabel_Profit.setName("jLabel_Profit"); // NOI18N

        jComboBox_ItemCategory.setEditable(true);
        jComboBox_ItemCategory.setModel(new javax.swing.DefaultComboBoxModel(new Category[] {new Category(),}));
        jComboBox_ItemCategory.setAction(actionMap.get("jComboBox_ItemCategoryActionPerformed")); // NOI18N
        jComboBox_ItemCategory.setName("jComboBox_ItemCategory"); // NOI18N
        jComboBox_ItemCategory.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox_ItemCategoryActionPerformed(evt);
            }
        });

        jButton_NewCategory.setText(resourceMap.getString("jButton_NewCategory.text")); // NOI18N
        jButton_NewCategory.setName("jButton_NewCategory"); // NOI18N

        jComboBox_ItemDiscountRule.setModel(new javax.swing.DefaultComboBoxModel(new Discount[] { new Discount(), }));
        jComboBox_ItemDiscountRule.setName("jComboBox_ItemDiscountRule"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel_ItemForm)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel_TaxRate)
                                .addGap(41, 41, 41)
                                .addComponent(jTextField_ItemTaxRate, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel_Description)
                            .addComponent(jLabel_Category)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel_ExpirationDate)
                                .addGap(29, 29, 29)
                                .addComponent(jTextField_ItemExpireDate, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel_ItemID)
                                .addGap(18, 18, 18)
                                .addComponent(jTextField_ItemID, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel_ItemName)
                                .addGap(33, 33, 33)
                                .addComponent(jTextField_ItemName, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jComboBox_ItemCategory, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton_NewCategory)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jButton_SaveItem)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(closeButton)
                                        .addGap(48, 48, 48))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel_StoreID)
                                        .addGap(67, 67, 67)
                                        .addComponent(jTextField_StoreID, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jLabel_Profit)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                                        .addComponent(jTextField_ItemProfitPercentage, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jLabel_SellPrice)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                                        .addComponent(jTextField_ItemSellPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel_Cost)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                                        .addComponent(jTextField_ItemCost, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jLabel_OnSale)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jLabel_ItemQuantity)
                                        .addGap(65, 65, 65)
                                        .addComponent(jTextField_ItemQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jLabel_ItemRemoveDate)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jTextArea_ItemSoldDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jLabel_ItemAddDate)
                                        .addGap(61, 61, 61)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jComboBox_ItemDiscountRule, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jTextArea_ItemAddDate))))))))
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jTextField_ItemDescription, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(328, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel_ItemForm)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_StoreID)
                    .addComponent(jTextField_StoreID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel_Cost)
                            .addComponent(jTextField_ItemCost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel_SellPrice)
                            .addComponent(jTextField_ItemSellPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel_ItemID)
                            .addComponent(jTextField_ItemID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel_ItemName)
                            .addComponent(jTextField_ItemName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_Profit)
                    .addComponent(jTextField_ItemProfitPercentage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel_ExpirationDate)
                    .addComponent(jTextField_ItemExpireDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_ItemQuantity)
                    .addComponent(jTextField_ItemQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel_TaxRate)
                    .addComponent(jTextField_ItemTaxRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel_OnSale)
                            .addComponent(jComboBox_ItemDiscountRule, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextArea_ItemAddDate, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_ItemAddDate))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextArea_ItemSoldDate, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_ItemRemoveDate))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(closeButton)
                            .addComponent(jButton_SaveItem))
                        .addGap(37, 37, 37))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel_Category)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBox_ItemCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton_NewCategory))
                        .addGap(12, 12, 12)
                        .addComponent(jLabel_Description)
                        .addGap(143, 143, 143))))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGap(290, 290, 290)
                    .addComponent(jTextField_ItemDescription, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextField_ItemNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_ItemNameActionPerformed
        // TODO add your handling code here:
        try{
            String name = jTextField_ItemName.getText().trim().toLowerCase();
            theItem.setName(name);
        } catch (Exception e) {

        }
//        theItem.name = name;
}//GEN-LAST:event_jTextField_ItemNameActionPerformed

    private void jTextField_ItemIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_ItemIDActionPerformed
        // TODO add your handling code here:
        int UPC = Integer.parseInt(jTextField_ItemID.getText().trim().toLowerCase());
        theItem.setUPC(UPC);
//        theItem.UPC = UPC;
}//GEN-LAST:event_jTextField_ItemIDActionPerformed

    private void jTextField_ItemCostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_ItemCostActionPerformed
        // TODO add your handling code here:
        BigDecimal cost = new BigDecimal(jTextField_ItemCost.getText().trim().toLowerCase());
        theItem.setCost(cost);
//        theItem.cost = cost;
        jTextField_ItemCost.setText((theItem.getRetailPrice().divide(theItem.getCost())).toString());
}//GEN-LAST:event_jTextField_ItemCostActionPerformed

    private void jTextField_StoreIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_StoreIDActionPerformed
        // TODO add your handling code here:
        int storeID = Integer.parseInt(jTextField_StoreID.getText().trim().toLowerCase());
        theStore.setStoreId(storeID);
    }//GEN-LAST:event_jTextField_StoreIDActionPerformed

    private void jTextField_ItemSellPriceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_ItemSellPriceActionPerformed
        // TODO add your handling code here:
        BigDecimal price = new BigDecimal(jTextField_ItemSellPrice.getText().trim().toLowerCase());
        theItem.setRetailPrice(price);
//        theItem.retailPrice = price;
        jTextField_ItemCost.setText((theItem.getRetailPrice().divide(theItem.getCost())).toString());
    }//GEN-LAST:event_jTextField_ItemSellPriceActionPerformed

    private void jTextField_ItemTaxRateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_ItemTaxRateActionPerformed
        // TODO add your handling code here:
        BigDecimal taxrate = new BigDecimal(jTextField_ItemTaxRate.getText().trim().toLowerCase());
        theItem.setTaxRate(taxrate);
//        theItem.taxRate = taxrate;
    }//GEN-LAST:event_jTextField_ItemTaxRateActionPerformed

    private void jComboBox_ItemCategoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox_ItemCategoryActionPerformed
        // TODO add your handling code here:
        theCategory = (Category)jComboBox_ItemCategory.getSelectedItem();
    }//GEN-LAST:event_jComboBox_ItemCategoryActionPerformed

    private void jTextField_ItemExpireDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_ItemExpireDateActionPerformed
        try {
            // TODO add your handling code here:
            DateFormat date = new SimpleDateFormat("dd/MM/yyyy");
            Date expiryDate = (Date) date.parse(jTextField_ItemExpireDate.getText());
            theStock.setExpiryDate(expiryDate);
        } catch (ParseException ex) {
            Logger.getLogger(DigitShopAdminItemForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jTextField_ItemExpireDateActionPerformed

    private void jTextField_ItemQuantityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_ItemQuantityActionPerformed
        // TODO add your handling code here:
        int qty = Integer.parseInt(jTextField_ItemQuantity.getText().trim().toLowerCase());
        theStock.setQuantity(qty);
    }//GEN-LAST:event_jTextField_ItemQuantityActionPerformed

    private void jComboBox_ItemDiscountRuleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox_ItemDiscountRuleActionPerformed
        // TODO add your handling code here:
        theDiscountRule = (Discount_rule)jComboBox_ItemDiscountRule.getSelectedItem();
    }//GEN-LAST:event_jComboBox_ItemDiscountRuleActionPerformed

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton closeButton;
    private javax.swing.JButton jButton_NewCategory;
    private javax.swing.JButton jButton_SaveItem;
    private javax.swing.JComboBox jComboBox_ItemCategory;
    private javax.swing.JComboBox jComboBox_ItemDiscountRule;
    private javax.swing.JLabel jLabel_Category;
    private javax.swing.JLabel jLabel_Cost;
    private javax.swing.JLabel jLabel_Description;
    private javax.swing.JLabel jLabel_ExpirationDate;
    private javax.swing.JLabel jLabel_ItemAddDate;
    private javax.swing.JLabel jLabel_ItemForm;
    private javax.swing.JLabel jLabel_ItemID;
    private javax.swing.JLabel jLabel_ItemName;
    private javax.swing.JLabel jLabel_ItemQuantity;
    private javax.swing.JLabel jLabel_ItemRemoveDate;
    private javax.swing.JLabel jLabel_OnSale;
    private javax.swing.JLabel jLabel_Profit;
    private javax.swing.JLabel jLabel_SellPrice;
    private javax.swing.JLabel jLabel_StoreID;
    private javax.swing.JLabel jLabel_TaxRate;
    private javax.swing.JTextArea jTextArea_ItemAddDate;
    private javax.swing.JTextArea jTextArea_ItemSoldDate;
    private javax.swing.JTextField jTextField_ItemCost;
    private javax.swing.JTextField jTextField_ItemDescription;
    private javax.swing.JTextField jTextField_ItemExpireDate;
    private javax.swing.JTextField jTextField_ItemID;
    private javax.swing.JTextField jTextField_ItemName;
    private javax.swing.JTextField jTextField_ItemProfitPercentage;
    private javax.swing.JTextField jTextField_ItemQuantity;
    private javax.swing.JTextField jTextField_ItemSellPrice;
    private javax.swing.JTextField jTextField_ItemTaxRate;
    private javax.swing.JTextField jTextField_StoreID;
    // End of variables declaration//GEN-END:variables
    
}
